<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>点不到的按钮</title>
    <style>
      .container {
        background: lightgray;
        position: relative;
        width: 500px;
        height: 500px;
        margin: 0 auto;
      }
      #btn {
        position: absolute;
        left: 0;
        top: 0;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <button id="btn">点我呀！</button>
    </div>
    <script>
      function getRandom(min, max) {
        return Math.floor(Math.random() * (max - min) + min);
      }
      // 当用户鼠标移动到按钮上的时候，改变按钮的位置
      var btn = document.getElementById('btn');
      btn.onmouseover = function () {
        btn.style.left = getRandom(0, 500) + 'px';
        btn.style.top = getRandom(0, 500) + 'px';
      };
    </script>
  </body>
</html>
